﻿import { readFileSync } from "fs";
import { join } from "path";

class appContext {
    private _config: any;
    constructor() {
        var configContent: any;
        var env = process.env["ASPNETCORE_ENVIRONMENT"];
        if (env) {
            configContent = readFileSync("appsettings." + env + ".json", "utf8");
        } else {
            configContent = readFileSync("appsettings.json", "utf8");
        }
        this._config = JSON.parse(configContent);
    }
    map_vscode_path(path: string) {
        return join(this._config.vscode_path, path);
    }
    map_path(path: string) {
        return path;
        //if (path.toLocaleLowerCase() == this._config.vscode_path.toLocaleLowerCase()) {
        //    return path;
        //}
        //return join(this._config.vscode_path, path);
    }
    get typescriptSdkPath() {
        return this._config.tsdk_path;
    }
}

export var AppContext: appContext = new appContext();